package com.cloudkinto.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 * @author hua
 * @since 2024-12-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_platform_order_product")
@NoArgsConstructor
public class PlatformOrderProductDo extends Model<PlatformOrderProductDo> {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("order_id")
    private Long orderId;

    /**
     * 目前亚马逊标发用的到
     */
    @TableField("item_id")
    private String itemId;

    @TableField("platform_order_no")
    private String platformOrderNo;

    /**
     * 平台商品名称
     */
    @TableField("platform_product_name")
    private String platformProductName;

    @TableField("platform_parent_sku")
    private String platformParentSku;

    /**
     * 平台sku
     */
    @TableField("platform_sku")
    private String platformSku;

    /**
     * 平台数量
     */
    @TableField("platform_qty")
    private Integer platformQty;

    @TableField("product_id")
    private Long productId;

    /**
     * 系统sku
     */
    @TableField("sku")
    private String sku;

    /**
     * 系统数量
     */
    @TableField("qty")
    private Integer qty;

    /**
     * 1是api拉下来的 0 是匹配的系统sku
     */
    @TableField("sku_type")
    private Integer skuType;

    public Integer getSkuType() {
        if (skuType == null) {
            return 0;
        }
        return skuType;
    }

    @TableField("currency_code")
    private String currencyCode;

    @TableField("item_amount")
    private BigDecimal itemAmount;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @TableField("create_by")
    private Long createBy;
    @TableField("update_time")
    private Date updateTime;

    @TableField("update_by")
    private Long updateBy;


    @TableField("delete_time")
    private Date deleteTime;

    @TableField("delete_by")
    private Long deleteBy;

    @TableField("delete_flag")
    @TableLogic
    private Integer deleteFlag;

    @TableField("sku_info")
    private String skuInfo;

    @TableField("delvdate_info")
    private String delvdateInfo;

    public PlatformOrderProductDo(Long orderId, String platformOrderNo, String platformParentSku, String platformSku, Integer platformQty, Long productId, String sku, Integer qty, Integer skuType, String currencyCode) {
        this.orderId = orderId;
        this.platformOrderNo = platformOrderNo;
        this.platformParentSku = platformParentSku;
        this.platformSku = platformSku;
        this.platformQty = platformQty;
        this.productId = productId;
        this.sku = sku;
        this.qty = qty;
        this.skuType = skuType;
        this.currencyCode = currencyCode;
    }

    public BigDecimal getItemAmount() {
        if (itemAmount == null) {
            return BigDecimal.ZERO;
        }
        return itemAmount;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
